var express = require('express');
var router = express.Router();

const typeApi = require("../api/type");

//获取一级路由
router.get("/", async function (req, res, next) {
    const data = await typeApi.get(req.query)
    res.send(data)
})

//添加一级路由
router.post("/add", async function (req, res, next) {
    const data = await typeApi.add(req.body);
    res.send(data)
});
//查询一级路由

//删除一级
router.delete("/del/:_id", async function (req, res, next) {
    const { _id } = req.params;
    const data = await typeApi.del({ _id });
    res.send(data)
})

//修改一级类别名称
router.put("/eit/:_id", async function (req,res,next){
    const { _id } = req.params;
    const typeOne = req.body;
    const data = await typeApi.upDate({_id,typeOne})
    res.send(data)
})

module.exports = router;